-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify all existing Telemetry types to implement IExtension #890
Conversation
…ialization module does that.
… for ISerialziationWriter
/// <summary> | ||
/// Deeply clones the Extension of <see cref="AvailabilityTelemetry"/> object. | ||
/// </summary> | ||
IExtension IExtension.DeepClone() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not ideal. DeepClone
needs to return ITelemetry
so you can pass it to the processors and initializers. So maybe ITelemetry
should be implementing IExtension
?
{ | ||
serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); | ||
this.WriteEnvelopeProperties(serializationWriter); | ||
Utils.CopyDictionary(this.Context.GlobalProperties, this.Data.properties); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serialize shouldn't mutate an object. Move dictionary copying some other place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed this.
/// <inheritdoc/> | ||
public void Serialize(ISerializationWriter serializationWriter) | ||
{ | ||
serializationWriter.WriteProperty("name", this.WriteTelemetryName(TelemetryName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if AvailabilityTelemetry
responsible for the entire envelope - it also need to serialize things like flags
and samplingPercentage
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its doing it next line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments for AvailabilityTelemetry
IExtension for extensions. ISerializableWithWriter for classes emitting serialization info.
…ializableWithWriter, ITelemetry dont implement the interface to avoid conufsion with the IExtension in ITelemetry
…ize method to follow the practise of NOT modifying data within serialize method.
@@ -3,16 +3,7 @@ | |||
/// <summary> | |||
/// Interface for defining strongly typed extensions to telemetry types. | |||
/// </summary> | |||
public interface IExtension | |||
public interface IExtension : ISerializableWithWriter, ICloneable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we still need ISerializableWithWriter
as a separate interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its now used by all the InternalData classes. The main classes like RequestTelemetry invokes serialize on the InternalData..
@@ -52,9 +52,11 @@ | |||
<PackageReference Include="MicroBuild.Core" Version="0.3.0"> | |||
<PrivateAssets>All</PrivateAssets> | |||
</PackageReference> | |||
<!-- | |||
<PackageReference Include="PublicApiAnalyzer" Version="1.0.0-alpha001"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unintended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will enable it back once other comments are addressed. I chose to modify public.shipped.txt only after everything else is ready
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I start review by looking at these files. Especially when there are so many files in PR. I'd appreciate if you can keep updating API files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. I have enabled it back and modified all public api files to reflect correct APIs. ( I disabled it because it was a disturbance while i was still tweaking API!)
/// <summary> | ||
/// Partial class to implement ISerializableWithWriter | ||
/// </summary> | ||
internal partial class RemoteDependencyData : ISerializableWithWriter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps Sanitize
can be moved to this interface as well at some point
/// <summary> | ||
/// Interface for defining method to Deeply clone the members. | ||
/// </summary> | ||
public interface ICloneable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only consumer of this interface is IExtension. Why we need it as an interface then? Just define a method on that interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few more comments. Overall looks better
…ing before calling seiralize
@SergeyKanzhelev Pubic API files added back. Please continue reviewing. |
@@ -178,6 +178,18 @@ public ITelemetry DeepClone() | |||
return new AvailabilityTelemetry(this); | |||
} | |||
|
|||
/// <inheritdoc/> | |||
public void Serialize(ISerializationWriter serializationWriter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks better now.... Now talk about usage of it - is it what our partners expect. I wonder if we need to have separate methods for envelope and separate for data
part of it. This way envelope structure is not forced on consumer and there is a choice to optimize an envelope structure for specific channels. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you switch to use these serializes instead of current one in a separate PR?
Following up on this PR (#875) which introduced the notion of
IExtension
( #871) which enabled strongly typed extensions to existing types.This PR makes all existing types (like RequestTelemetry, DependencyTelemetry etc) implement
IExtension
, thereby emitting serialization information. Current serialization logic is replaced with this one. With this, customers using non-AI backend/channel can use the existing types and serialize them to any format (bond,xml etc).Note: Few items like updating public API in api analyzer is pending.
For significant contributions please make sure you have completed the following items: